<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <title>根据用户屏幕的色彩深度设置颜色</title>
</head>
<body>
<script>
    var colorDepth = screen.colorDepth;
    switch (colorDepth) {
        case 1:
        case 4:
            document.bgColor = 'white';
            break;
        case 8:
        case 15:
        case 16:
            document.bgColor = 'blue';
            break;
        case 24:
        case 32:
            document.bgColor = 'sykblue';
            break;
        default:
            document.bgColor = 'white';
    }
    document.write('Your screen supports ' + colorDepth + 'bit color');
</script>
</body>
</html>